﻿var mouseX;
var mouseY;

jQuery(document).ready(function () {
    $(document).mousemove(function (e) {
        mouseX = e.pageX;
        mouseY = e.pageY;
    });
})

function ShowTooltip(id, name, type, desc) {

    var tooltip = document.getElementById(id);

    // Remove child if any.
    if (tooltip.lastChild != null)
        tooltip.removeChild(tooltip.lastChild);
    
    tooltip.style.left = mouseX + "px";
    tooltip.style.top = mouseY + "px";
    
    var ul = document.createElement("ul");

    var li_name = document.createElement("li");
    var li_type = document.createElement("li");
    var li_desc = document.createElement("li");

    li_name.style.fontWeight = "bold";
    li_name.style.marginBottom = "7px";

    li_type.style.marginBottom = "3px";
    li_type.style.marginLeft = "5px";

    li_desc.style.marginBottom = "3px";
    li_desc.style.marginLeft = "5px";

    li_name.innerHTML = name;
    li_type.innerHTML = '<span style="font-weight:bold;">Type:</span> ' + type;
    li_desc.innerHTML = '<span style="font-weight:bold;">Description:</span> ' + desc;

    ul.appendChild(li_name);
    ul.appendChild(li_type);
    ul.appendChild(li_desc);

    tooltip.appendChild(ul);

    tooltip.style.visibility = "visible";
}

function HideTooltip(id) {
    var tooltip = document.getElementById(id);
    tooltip.style.visibility = "hidden";
}